#include <stdio.h>

void powerset(int n, int *set, int size, int *ret, int rsize)
{
    int i;

    if (n > size)
    {
        printf("[");
        for (i = 0; i < rsize; i++) {
            printf("%d ", ret[i]);        
        }
        printf("]\n");
    }
    else
    {
        /* set the n */ 
        ret[rsize++] = set[n-1];
        powerset(n+1, set, size, ret, rsize);

        /* not set n */
        rsize --;
        powerset(n+1, set, size, ret, rsize<0?0:rsize);
    }
}

int main(int argc, char const* argv[])
{
    int ret[10000];

    int set[] = {1, 2, 3};
    powerset(1, set, 3, ret, 0);

    return 0;
}
